package com.xhwl.logistics.service.impl.http;

import com.google.common.base.Strings;
import com.xhwl.common.exception.BusinessException;
import com.xhwl.logistics.bo.cent.VehicleIntegratedConfigBO;
import com.xhwl.logistics.bo.cent.VehicleParkingInfoBO;
import com.xhwl.logistics.component.JsonConverter;
import com.xhwl.logistics.component.Sign;
import com.xhwl.logistics.dto.CarDTO;
import com.xhwl.logistics.dto.http.*;
import com.xhwl.logistics.dto.http.manipulation.AddCarBlackKeTopDTO;
import com.xhwl.logistics.dto.http.manipulation.DeleteCarBlackKeTopDTO;
import com.xhwl.logistics.dto.http.query.*;
import com.xhwl.logistics.enums.VehicleParkingLotHandlerEnum;
import com.xhwl.logistics.service.cent.QueryDeviceService;
import com.xhwl.logistics.service.http.IKeTopHttpService;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Slf4j
//@Service
public class KeTopHttpServiceImpl {

    @Autowired
    private Sign sign;

    @Autowired
    private JsonConverter jsonConverter;

    @Autowired
    private QueryDeviceService queryDeviceService;

    private final Map<String, IKeTopHttpService> map = new HashMap<>();

    @Value("${http-proxy.ip:-1}")
    private String ip;
    @Value("${http-proxy.port:-1}")
    private Integer port;

//    public FreeSpaceNumberDTO queryFreeSpaceNumber(VehicleIntegratedConfigurationBO vehicleIntegratedConfigurationBO, QueryFreeSpaceNumberDTO queryFreeSpaceNumberDTO) {
//        final String serviceCode = "getFreeSpaceNum";
//
//        Integer parkId = vehicleIntegratedConfigurationBO.getParkId();
//
//        String host = vehicleIntegratedConfigurationBO.getHost() + "/";
//
//        String appId = vehicleIntegratedConfigurationBO.getAppId();
//        String appSecret = vehicleIntegratedConfigurationBO.getAppSecret();
//        String version = vehicleIntegratedConfigurationBO.getVersion();
//
//        IKeTopHttpService keTopHttpService = new Retrofit.Builder().baseUrl(host).addConverterFactory(GsonConverterFactory.create()).build().create(IKeTopHttpService.class);
//
//        sign.preHandle(queryFreeSpaceNumberDTO, appId, parkId, serviceCode);
//        sign.sign(queryFreeSpaceNumberDTO, appSecret);
//
//        Call<KeTopResponseDTO> call = keTopHttpService.freeSpaceNumber(version, queryFreeSpaceNumberDTO);
//        Response<KeTopResponseDTO> response;
//        try {
//            response = call.execute();
//        } catch (IOException e) {
//            throw new BusinessException("请求科拓查询空闲车位接口出现异常");
//        }
//
//        int code = response.code();
//        if (code!=200) {
//            throw new BusinessException("请求科拓查询空闲车位接口返回的http状态码不为200");
//        }
//
//        KeTopResponseDTO keTopResponseDTO = response.body();
//
//        log.info("KeTopResponseDTO: " + keTopResponseDTO);
//
//        String resCode = Objects.requireNonNull(keTopResponseDTO).getResCode();
//        if (!"0".equals(resCode)) {
//            throw new BusinessException("请求科拓查询空闲车位接口返回的resCode不为0");
//        }
//        return jsonConverter.stringToObject(Objects.requireNonNull(keTopResponseDTO).getData(), FreeSpaceNumberDTO.class);
//    }

//    public FreeSpaceNumberKeTopDTO queryFreeSpaceNumber(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryFreeSpaceNumberKeTopDTO queryFreeSpaceNumberKeTopDTO) {
//        final String serviceCode = "getFreeSpaceNum";
//
//        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
//
//        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
//
//        String host = vehicleParkingInfoBO.getHost() + "/";
//
//        String appId = vehicleParkingInfoBO.getAppId();
//        String appSecret = vehicleParkingInfoBO.getAppSecret();
//        String version = vehicleParkingInfoBO.getVersion();
//
//        IKeTopHttpService keTopHttpService = new Retrofit.Builder().baseUrl(host).addConverterFactory(GsonConverterFactory.create()).build().create(IKeTopHttpService.class);
//
//        sign.preHandle(queryFreeSpaceNumberKeTopDTO, appId, parkId, serviceCode);
//        sign.sign(queryFreeSpaceNumberKeTopDTO, appSecret);
//
//        Call<ResponseKeTopDTO> call = keTopHttpService.freeSpaceNumber(version, queryFreeSpaceNumberKeTopDTO);
//        Response<ResponseKeTopDTO> response;
//        try {
//            response = call.execute();
//        } catch (IOException e) {
//            throw new BusinessException("请求科拓查询空闲车位接口出现异常");
//        }
//
//        int code = response.code();
//        if (code!=200) {
//            throw new BusinessException("请求科拓查询空闲车位接口返回的http状态码不为200");
//        }
//
//        ResponseKeTopDTO responseKeTopDTO = response.body();
//
//        log.info("KeTopResponseDTO: " + responseKeTopDTO);
//
//        String resCode = Objects.requireNonNull(responseKeTopDTO).getResCode();
//        if (!"0".equals(resCode)) {
//            throw new BusinessException("请求科拓查询空闲车位接口返回的resCode不为0");
//        }
//        return jsonConverter.stringToObject(Objects.requireNonNull(responseKeTopDTO).getData(), FreeSpaceNumberKeTopDTO.class);
//    }

    private IKeTopHttpService getKeTopHttpService(VehicleIntegratedConfigBO vehicleIntegratedConfigBO) {
        return map.get(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getHost());
    }

    private String keyTopResponseHandle(Response<ResponseKeTopDTO> response) {
        return keyTopResponseHandle(response, null);
    }
    private String keyTopResponseHandle(Response<ResponseKeTopDTO> response, String exceptionMessage) {
        if (response.code()!=200) {
            throw new BusinessException("请求科拓查询接口返回的http状态码不为200");
        }
        ResponseKeTopDTO body = response.body();
        if (Objects.isNull(body)) {
            throw new BusinessException("请求科拓查询接口返回的响应消息体为空");
        }
        if (!"0".equals(body.getResCode())) {
            if (Strings.isNullOrEmpty(exceptionMessage)) {
                throw new BusinessException("请求科拓查询接口返回的业务码（resCode）不为0，业务异常");
            } else {
                throw new BusinessException(exceptionMessage);
            }
        }
        return body.getData();
    }

    public FreeSpaceNumberKeTopDTO queryFreeSpaceNumber(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryFreeSpaceNumberKeTopDTO queryFreeSpaceNumberKeTopDTO) {
        final String serviceCode = "getFreeSpaceNum";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryFreeSpaceNumberKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryFreeSpaceNumberKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).freeSpaceNumber(version, queryFreeSpaceNumberKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询空闲车位接口出现IO异常");
        }
        log.info("返回的结果为："+response);
        log.info("返回的结果数据为："+response.body());
        return jsonConverter.stringToObject(keyTopResponseHandle(response), FreeSpaceNumberKeTopDTO.class);
    }

    public FreeSpaceNumberExtKeTopDTO queryFreeSpaceNumberExt(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryFreeSpaceNumberKeTopDTO queryFreeSpaceNumberKeTopDTO) {
        final String serviceCode = "getFreeSpaceNumExt";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryFreeSpaceNumberKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryFreeSpaceNumberKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).freeSpaceNumberExt(version, queryFreeSpaceNumberKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询空闲车位扩展接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询空闲车位扩展接口业务异常"), FreeSpaceNumberExtKeTopDTO.class);
    }

    public CarLocationKeTopDTO queryCarLocation(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCarLocationKeTopDTO queryCarLocationKeTopDTO) {
        final String serviceCode = "getCarLocInfo";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCarLocationKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCarLocationKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).carLocation(version, queryCarLocationKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车辆位置接口出现IO异常");
        }
        String responseBusinessData = keyTopResponseHandle(response, "请求科拓查询车辆位置接口业务异常，输入的车牌号不存在");
        if ("{}".equals(responseBusinessData)) {
            throw new BusinessException("请求科拓查询车辆位置接口返回的业务数据为空，输入的车牌号不存在");
        }
        return jsonConverter.stringToObject(responseBusinessData, CarLocationKeTopDTO.class);
    }

    public CarRouteKeTopDTO queryCarRoute(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCarRouteKeTopDTO queryCarRouteKeTopDTO) {
        final String serviceCode = "getCarRoute";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCarRouteKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCarRouteKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).carRoute(version, queryCarRouteKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车辆线路接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车辆线路接口业务异常，输入的附近车位不存在"), CarRouteKeTopDTO.class);
    }

    public ParkingLotInfoKeTopDTO queryParkingLotInfo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCommonKeTopDTO queryCommonKeTopDTO) {
        final String serviceCode = "getParkingLotInfo";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCommonKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCommonKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).parkingLotInfo(version, queryCommonKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车场信息接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车场信息接口业务异常"), ParkingLotInfoKeTopDTO.class);
    }

    public ParkingLotAreaKeTopDTO queryParkingLotArea(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCommonKeTopDTO queryCommonKeTopDTO) {
        final String serviceCode = "getParkingPlaceArea";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCommonKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCommonKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).parkingLotArea(version, queryCommonKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车场区域接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车场区域接口业务异常"), ParkingLotAreaKeTopDTO.class);
    }

    public ParkingLotPassageKeTopDTO queryParkingLotPassage(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryParkingLotPassageKeTopDTO queryParkingLotPassageKeTopDTO) {
        final String serviceCode = "getParkingNode";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryParkingLotPassageKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryParkingLotPassageKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).parkingLotPassage(version, queryParkingLotPassageKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车场通道接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车场通道接口业务异常"), ParkingLotPassageKeTopDTO.class);
    }

    public ParkingLotDeviceKeTopDTO queryParkingLotDevice(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryParkingLotDeviceKeTopDTO queryParkingLotDeviceKeTopDTO) {
        final String serviceCode = "getDeviceList";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryParkingLotDeviceKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryParkingLotDeviceKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).parkingLotDevice(version, queryParkingLotDeviceKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车场设备接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车场设备接口业务异常"), ParkingLotDeviceKeTopDTO.class);
    }

    public ParkingLotDeviceKeTopDTO queryDeviceStatus(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryParkingLotDeviceKeTopDTO queryParkingLotDeviceKeTopDTO) {
        final String serviceCode = "getDeviceStatus";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryParkingLotDeviceKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryParkingLotDeviceKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).parkingLotDeviceStatus(version, queryParkingLotDeviceKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车场设备状态接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车场设备状态接口业务异常"), ParkingLotDeviceKeTopDTO.class);
    }

    public CarInParkingLotKeTopDTO queryCarInfo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCarInParkingLotKeTopDTO queryCarInParkingLotKeTopDTO) {
        final String serviceCode = "queryCarInfo";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCarInParkingLotKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCarInParkingLotKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).carInfo(version, queryCarInParkingLotKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车场在场车辆接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车场在场车辆接口业务异常"), CarInParkingLotKeTopDTO.class);
    }

    public CarChargeKeTopDTO queryCarCharge(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCarChargeKeTopDTO queryCarChargeKeTopDTO) {
        final String serviceCode = "getCarCardChargeList";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCarChargeKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCarChargeKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).carCharge(version, queryCarChargeKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车辆充值信息接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车辆充值信息接口业务异常"), CarChargeKeTopDTO.class);
    }

    public CarListKeTopDTO queryCarList(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCarListKeTopDTO queryCarListKeTopDTO) {
        final String serviceCode = "getCarCardList";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCarListKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCarListKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).carList(version, queryCarListKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车辆列表信息接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车辆列表信息接口业务异常"), CarListKeTopDTO.class);
    }

    public CarBlackKeTopDTO queryCarBlack(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCarBlackKeTopDTO queryCarBlackKeTopDTO) {
        final String serviceCode = "queryCarBlackInfo";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCarBlackKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCarBlackKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).carBlack(version, queryCarBlackKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车辆黑名单列表接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车辆黑名单列表接口业务异常"), CarBlackKeTopDTO.class);
    }

    public void addCarBlack(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, AddCarBlackKeTopDTO addCarBlackKeTopDTO) {
        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        sign.sign(addCarBlackKeTopDTO, vehicleParkingInfoBO, "addCarBlackInfo");

        String version = vehicleParkingInfoBO.getVersion();
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).addCarBlack(version, addCarBlackKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓增加车辆黑名单记录接口出现IO异常");
        }
        keyTopResponseHandle(response, "请求科拓增加车辆黑名单记录接口业务异常");
    }

    public void deleteCarBlack(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, DeleteCarBlackKeTopDTO deleteCarBlackKeTopDTO) {
        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        sign.sign(deleteCarBlackKeTopDTO, vehicleParkingInfoBO, "delCarBlackInfo");

        String version = vehicleParkingInfoBO.getVersion();
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).deleteCarBlack(version, deleteCarBlackKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓删除车辆黑名单记录接口出现IO异常");
        }
        keyTopResponseHandle(response, "请求科拓删除车辆黑名单记录接口业务异常");
    }

    public CardRuleKeTopDTO queryCardRule(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCardRuleKeTopDTO queryCardRuleKeTopDTO) {
        final String serviceCode = "getCarCardRule";

        VehicleParkingInfoBO vehicleParkingInfoBO = vehicleIntegratedConfigBO.getVehicleParkingInfoBO();
        Integer parkId = Integer.valueOf(vehicleParkingInfoBO.getParkId());
        String appId = vehicleParkingInfoBO.getAppId();
        String appSecret = vehicleParkingInfoBO.getAppSecret();
        String version = vehicleParkingInfoBO.getVersion();

        sign.preHandle(queryCardRuleKeTopDTO, appId, parkId, serviceCode);
        sign.sign(queryCardRuleKeTopDTO, appSecret);

        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).cardRule(version, queryCardRuleKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓查询车卡充值规则接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓查询车卡充值规则接口业务异常"), CardRuleKeTopDTO.class);
    }

    /**
     * 对接科拓，用户车位预订
     */
    public ReserveSpaceKeTopDTO reserveSpace(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryReserveSpaceKeTopDTO queryReserveSpaceKeTopDTO) {
        final String serviceCode = "reserveSpace";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryReserveSpaceKeTopDTO对象里面
        sign.preHandle(queryReserveSpaceKeTopDTO, appId, parkId, serviceCode);
        //为queryReserveSpaceKeTopDTO对象添加签名
        sign.sign(queryReserveSpaceKeTopDTO, appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).reserveSpace(version, queryReserveSpaceKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try{
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓用户车位预订接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓用户车位预订接口业务异常"), ReserveSpaceKeTopDTO.class);
    }

    /**
     * 对接科拓，预订车位查询
     */
    public ReservableKeTopDTO getReservableInfo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryReservableInfoKeTopDTO queryReservableInfoKeTopDTO){
        final String serviceCode = "getReservableInfo";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryReservableInfoKeTopDTO对象里面
        sign.preHandle(queryReservableInfoKeTopDTO,appId,parkId,serviceCode);
        //为queryReservableInfoKeTopDTO对象添加签名
        sign.sign(queryReservableInfoKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).getReservableInfo(version, queryReservableInfoKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try{
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓预订车位查询接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response, "请求科拓预订车位查询接口业务异常"), ReservableKeTopDTO.class);
    }

    /**
     * 对接科拓，车位预订取消
     */
    public void cancelReserveSpace(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCancelReserveKeTopDTO queryCancelReserveKeTopDTO){
        final String serviceCode = "cancelReserveSpace";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryCancelReserveKeTopDTO对象里面
        sign.preHandle(queryCancelReserveKeTopDTO,appId,parkId,serviceCode);
        //为queryCancelReserveKeTopDTO对象添加签名
        sign.sign(queryCancelReserveKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).cancelReserveSpace(version, queryCancelReserveKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try{
            response = call.execute();
        } catch (IOException e) {
            throw new BusinessException("执行请求科拓车位预订取消接口出现IO异常");
        }
        keyTopResponseHandle(response, "请求科拓预订车位预订取消接口业务异常");
    }

    /**
     * 对接科拓，道闸控制
     */
    public GateControlKeTopDTO gateControl(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryGateControlKeTopDTO queryGateControlKeTopDTO){
        final String serviceCode = "gateControl";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(queryGateControlKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(queryGateControlKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpSerice服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).gateControl(version, queryGateControlKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求科拓道闸控制接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response,"请求科拓道闸控制接口业务异常"),GateControlKeTopDTO.class);
    }

    //该接口只支持5.x版本的收费系统，而现在收费系统的版本是6.x版本的，故该接口暂不用
    /**
     * 对接科拓，查询通道状态
     */
    public GateControlListKeTopDTO gateControlList(VehicleIntegratedConfigBO vehicleIntegratedConfigBO,QueryGateControlKeTopDTO queryGateControlKeTopDTO){
        final String serviceCode = "getParkingNodeStatus";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(queryGateControlKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(queryGateControlKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).getGateStatus(version, queryGateControlKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求科拓查询道闸状态接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response,"请求科拓查询道闸状态接口业务异常"),GateControlListKeTopDTO.class);
    }

    /**
     * 对接科拓，根据车牌号查询订单
     */
    public String getParkingPaymentInfo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, CarBillKeTopDTO carBillKeTopDTO){
        final String serviceCode = "getParkingPaymentInfo";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到carBillKeTopDTO对象里面
        sign.preHandle(carBillKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(carBillKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).getParkingPaymentInfo(version, carBillKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求科拓查询订单接口出现IO异常");
        }

        //由于科拓的这个接口的逻辑是如果订单中没有该车牌号的信息，那么访问就会报1001认证异常，故做以下操作
        if (response.code()!=200) {
            throw new BusinessException("请求科拓查询接口返回的http状态码不为200");
        }
        ResponseKeTopDTO body = response.body();
        if (Objects.isNull(body)) {
            throw new BusinessException("请求科拓查询接口返回的响应消息体为空");
        }
        if (!"0".equals(body.getResCode())) {
            if("1001".equals(body.getResCode())){
                return "0";
            }else{
                throw new BusinessException("请求科拓查询订单接口业务异常");
            }
        }
        return body.getData();
    }

    //retrofit动态url的解决方案也可选择：使用@Url在请求接口中定义
    @PostConstruct
    public void init() {
        List<VehicleIntegratedConfigBO> vehicleIntegratedConfigBOS = queryDeviceService.queryIntegratedConfigs();
        vehicleIntegratedConfigBOS.stream()
                .filter(vehicleIntegratedConfigBO -> VehicleParkingLotHandlerEnum.VEHICLE_PARKINGLOT_KETOP.getProductId().equals(vehicleIntegratedConfigBO.getVehicleSystemInfoBO().getProductId()))
                .map(vehicleIntegratedConfigBO -> vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getHost())
                .filter(host -> !Strings.isNullOrEmpty(host))
                .distinct()
                .forEach(host -> {
                    log.info("host:{}", ip+":"+port);
                    IKeTopHttpService keTopHttpService;
                    if("-1".equals(ip) || Integer.valueOf(-1).equals(port)) {
                        Retrofit retrofit = new Retrofit.Builder().baseUrl(host + "/").addConverterFactory(GsonConverterFactory.create()).build();
                        keTopHttpService = retrofit.create(IKeTopHttpService.class);
                    } else {
                        OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
                        String proxyHost = ip;
                        Integer proxyPort = port;
                        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
                        clientBuilder.proxy(proxy);
                        Retrofit retrofit = new Retrofit.Builder().baseUrl(host + "/").client(clientBuilder.build()).addConverterFactory(GsonConverterFactory.create()).build();
                        keTopHttpService = retrofit.create(IKeTopHttpService.class);
                    }
                    map.put(host, keTopHttpService);
                });
    }


    /**
     * 对接科拓，查询车场收入统计
     */
    public InComeReportKeTopDTO getInComeReport(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, GetInComeReportKeTopDTO getInComeReportKeTopDTO){
        final String serviceCode = "getInComeReport";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(getInComeReportKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(getInComeReportKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).getInComeReport(version, getInComeReportKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求科拓查询车场收入统计接口出现IO异常");
        }
        return jsonConverter.stringToObject(keyTopResponseHandle(response,"请求科拓查询车场收入统计接口业务异常"),InComeReportKeTopDTO.class);
    }


    /**
     * 新增固定车
     */
    public String addCarCardNo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, CarAddKeTopDTO carAddKeTopDTO) {
        final String serviceCode = "addCarCardNo";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(carAddKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(carAddKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).addCarCardNo(version, carAddKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求固定车新增接口出现IO异常");
        }
        return keyTopResponseHandle(response,"请求科拓固定车新增接口业务异常");
    }


    /**
     * 固定车审核
     */
    public String auditCardRecharge(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, CarAuditKeTopDTO carAuditKeTopDTO) {
        final String serviceCode = "auditCardRecharge";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(carAuditKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(carAuditKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).auditCardRecharge(version, carAuditKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求固定车审批接口出现IO异常");
        }
        return keyTopResponseHandle(response,"请求科拓固定车审批接口业务异常");
    }

    /**
     * 删除固定车
     * @param vehicleIntegratedConfigBO
     * @param cardId
     */
    public void delCarCardInfo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, String cardId) {
        final String serviceCode = "delCarCardInfo";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        CarDeleteKeTopDTO carDeleteKeTopDTO = new CarDeleteKeTopDTO();
        carDeleteKeTopDTO.setCardId(cardId);

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(carDeleteKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(carDeleteKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).delCarCardInfo(version, carDeleteKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求固定车删除接口出现IO异常");
        }
        keyTopResponseHandle(response,"请求科拓固定车删除接口业务异常");
    }

    /**
     * 固定车修改
     */
    public String modifyCarCardNo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, CarAddKeTopDTO carAddKeTopDTO) {
        final String serviceCode = "modifyCarCardNo";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(carAddKeTopDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(carAddKeTopDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).auditCardRecharge(version, carAddKeTopDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求固定车修改接口出现IO异常");
        }
        return keyTopResponseHandle(response,"请求科拓固定车修改接口业务异常");
    }

    /**
     * 固定车查询接口
     */
    public CarDTO getCarCardInfo(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryCarCardInfoDTO queryCarCardInfoDTO) {
        final String serviceCode = "getCarCardInfo";

        Integer parkId = Integer.valueOf(vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getParkId());
        String appId = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppId();
        String appSecret = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getAppSecret();
        String version = vehicleIntegratedConfigBO.getVehicleParkingInfoBO().getVersion();

        //将上面的信息注入到queryGateControlKeTopDTO对象里面
        sign.preHandle(queryCarCardInfoDTO,appId,parkId,serviceCode);
        //为queryGateControlKeTopDTO对象添加签名
        sign.sign(queryCarCardInfoDTO,appSecret);

        //获得使用了Retrofit网络库的IKeTopHttpService服务类
        Call<ResponseKeTopDTO> call = getKeTopHttpService(vehicleIntegratedConfigBO).getCarCardInfo(version, queryCarCardInfoDTO);
        Response<ResponseKeTopDTO> response;
        try {
            response = call.execute();
        }catch (IOException e){
            throw new BusinessException("执行请求固定车查询接口出现IO异常");
        }
        String data = keyTopResponseHandle(response,"请求科拓固定车查询接口业务异常");
        if(data == null || ("").equals(data)) {
            throw new BusinessException("没有查询到该固定车");
        }
        return jsonConverter.stringToObject(data, CarDTO.class);
    }

}
